//
//  IWTitleButton.m
//  WeiBo_OC
//
//  Created by WONG on 16/2/17.
//  Copyright © 2016年 cheuhui. All rights reserved.
//

#import "IWTitleButton.h"

// 间距
#define MARGIN 5

@implementation IWTitleButton

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.titleLabel.x = 0;
    
    self.imageView.x = CGRectGetWidth(self.titleLabel.frame) + MARGIN;
    
    self.width = self.titleLabel.width + self.imageView.width + MARGIN;
    self.centerX = self.superview.width * 0.5;
}

- (void)setTitle:(NSString *)title forState:(UIControlState)state{
    [super setTitle:title forState:state];
    [self sizeToFit];
}

- (void)setImage:(UIImage *)image forState:(UIControlState)state{
    [super setImage:image forState:state];
    [self sizeToFit];
}

@end
